-
Notifications
You must be signed in to change notification settings - Fork 38
Tweak grammar of primitive list in externals #415
Conversation
Fixes #412 Currently the grammar allows for a list of primitives in an external declaration: i.e. `"hi" "hx"` in `external f: (int, int) => int = "hi" "hx"`. This stems from the fact that user primitives with arity greater than 5 should be implemented by two C functions. The first function, to be used in conjunction with the bytecode compiler ocamlc, receives two arguments: a pointer to an array of OCaml values (the values for the arguments), and an integer which is the number of arguments provided. The other function, to be used in conjunction with the native-code compiler ocamlopt, takes its arguments directly. However in the case of compiling to JS, we don't need to deal with this. In order to reduce some complexity, we'll now parse just one primitive.
cc @bobzhang |
2 │ external setTimeout: (unit => unit, int) => float = | ||
3 │ | ||
|
||
An external requires the name of the JS value you're referring to, like "setTimeout". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @bloodyowl, how does this sound? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this only occur with:
external setTimeout: (unit => unit, int) => float =
or also with
external setTimeout: (unit => unit, int) => float
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently only implemented for the first. Can also add one for the latter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go for:
2 | external setTimeout: (unit => unit, int) => float =
3 |
This external is missing the JavaScript value it is supposed to reference (like `= "setTimeout"`)
But the one is your PR looks good to me as well 😊
we may also need consider multiple line string support:
Edit: it seems |
Yes, |
sounds good, as long as we have a way to encode multiple line string, it should be fine |
Fixes #412
Currently the grammar allows for a list of primitives in an external declaration: i.e.
"hi" "hx"
inexternal f: (int, int) => int = "hi" "hx"
. This stems from the fact that user primitives with arity greater than 5 should be implemented by two C functions. The first function, to be used in conjunction with the bytecode compiler ocamlc, receives two arguments: a pointer to an array of OCaml values (the values for the arguments), and an integer which is the number of arguments provided. The other function, to be used in conjunction with the native-code compiler ocamlopt, takes its arguments directly.However in the case of compiling to JS with ReScript, we don't need to deal with this. In order to reduce some complexity, we'll now parse just one primitive.